<?php
/**
 * 回想起昨天，仿佛在昨天。
 *
 * @package To Love
 * @author wumingyouxia
 * @version 1.0
 * @link https://diyibailingyici.chuangdangjianghudewumingyouxia.cn/
 */

if (!defined('__TYPECHO_ROOT_DIR__')) exit;
?>

<?php
$wumingyouxia101_love = "";
if (isset($_GET['wumingyouxia101_love'])) {
    $wumingyouxia101_love = $_GET['wumingyouxia101_love'];
}
$siteUrl = str_replace('http://','',$this->options->siteUrl);
$siteUrl = rtrim(str_replace('https://','',$siteUrl),'/');
$linkSymbol = '∑£∮€∑';
$identification = $linkSymbol.'哈哈无名游侠的爱'; //中文可改

if($wumingyouxia101_love == "addWhisper"){
    //进入保存信息页面
    include $this->themeDir . 'insertData.php';
}else{
    $host = strval($_SERVER['HTTP_X_FORWARDED_HOST'] ?: $_SERVER['HTTP_HOST']);
    $hostHead = rtrim(str_replace($siteUrl,'',$host),'.');
    if(!$hostHead){
        //进入首页
        $this->need('home.php');
    }else{
        //中文(特殊文字)转 Punycode
        //idn_to_ascii("成",IDNA_NONTRANSITIONAL_TO_ASCII,INTL_IDNA_VARIANT_UTS46);
        //Punycode 转 中文
        $hostHead=idn_to_utf8($hostHead);
        $dataQuery = $this->db->select()->from('table.contents')
            ->where('title = ?', $hostHead.$identification)->limit(1);
        $dataQueryEnd = $this->db->fetchRow($dataQuery);
        if(!$dataQueryEnd){
            //没有数据，进入首页
            include $this->themeDir . 'home.php';
        }else{
            $loveInfo = json_decode($dataQueryEnd['text'],true);
            $password = $dataQueryEnd['password'];
            $loveInfo['title']=$loveInfo['title'] ? $loveInfo['title'] : "我想对你说";
            $loveInfo['whisper']=$loveInfo['whisper'] ? $loveInfo['whisper'] : "你是字里行间的隐喻，藏在开头，躲在结尾，断句里有笑意，韵脚里有深情，句句无你，却句句是你。";
            if($password){
                session_start();
                $redirect=0;
                $pass = $_SESSION['haha_tolove_MyPassWord'];
                if($pass){
                    //进入显示页面
                    updateCommentsNum($this->db,$dataQueryEnd['cid'],$dataQueryEnd['commentsNum']);
                    include $this->themeDir . 'show.php';
                }else{
                    //进入密码页面
                    $m = "";
                    if (isset($_GET['wumingyouxia101_mima'])) {
                        $m = $_GET['wumingyouxia101_mima'];
                    }
                    if($m && $m == $password){
                        $_SESSION['haha_tolove_MyPassWord']=$password;
                        $url=$host;
                        $redirect=1;
                    }
                    include $this->themeDir . 'pass.php';
                }
            }else{
                //进入显示页面
                updateCommentsNum($this->db,$dataQueryEnd['cid'],$dataQueryEnd['commentsNum']);
                include $this->themeDir . 'show.php';
            }
        }
    }
}

?>


